<template>
  <div class="not-logged-in-container">
    <div class="not-logged-in-content">
<!--      <div class="illustration">-->
<!--        <img src="@/assets/images/login-required.svg" alt="请先登录" />-->
<!--      </div>-->
      <h2 class="title">请先登录</h2>
      <p class="description">登录后即可{{ pageContent }}</p>
      <button class="login-button" @click="handleLogin">立即登录</button>
    </div>
  </div>
</template>

<script setup>
import { getCurrentInstance } from 'vue';
import { useRouter } from 'vue-router';

const props = defineProps({
  pageContent: {
    type: String,
    default: '查看该内容'
  }
});

const router = useRouter();
const { proxy } = getCurrentInstance();

const handleLogin = async () => {
  try {
    const { success } = await proxy.$login.show();
    if (success) {
      // 登录成功后刷新当前页面
      window.location.reload();
    }
  } catch (error) {
    console.error('登录失败:', error);
  }
};
</script>

<style scoped>
.not-logged-in-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
  padding: 20px;
}

.not-logged-in-content {
  text-align: center;
  max-width: 400px;
}

.illustration {
  margin-bottom: 24px;
}

.illustration img {
  width: 200px;
  height: auto;
}

.title {
  font-size: 24px;
  font-weight: 600;
  color: #333;
  margin-bottom: 12px;
}

.description {
  font-size: 16px;
  color: #666;
  margin-bottom: 24px;
}

.login-button {
  padding: 10px 32px;
  background: linear-gradient(90deg, #ff2442 0%, #ff416c 100%);
  color: white;
  border: none;
  border-radius: 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.login-button:hover {
  opacity: 0.9;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(255, 36, 66, 0.2);
}
</style> 